package com.yanqu.road.entity.activity.zhenhuan.config;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.utils.property.Property;
import com.yanqu.road.utils.property.PropertyHelper;
import com.yanqu.road.utils.string.StringUtils;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

@FieldTypeAnnotation(tableName = "t_s_activity_zhenhuan_story", desc = "甄嬛传第一阶段故事组合表")
public class ZhenHuanStoryConfig extends DataObject {
    @FieldTypeAnnotation(select = true, isIndex = true)
    private int activityId;
    @FieldTypeAnnotation(desc = "故事id", isIndex = true)
    private int id;
    @FieldTypeAnnotation(desc = "名称")
    private String name;
    @FieldTypeAnnotation(desc = "描述")
    private String desc;
    @FieldTypeAnnotation(desc = "妃子组合")
    private String concubineComb;
    @FieldTypeAnnotation(desc = "权重")
    private int weight;
    @FieldTypeAnnotation(desc = "奖励")
    private String reward;
    @FieldTypeAnnotation(desc = "品质")
    private int quality;
    @FieldTypeAnnotation(desc = "首次解锁奖励")
    private String firstUnlockReward;

    private List<Integer> concubineList = new ArrayList<>();
    private List<List<Property>> rewardList = new ArrayList<>();

    public ZhenHuanStoryConfig(ResultSet rs) throws SQLException {
        this.activityId = rs.getInt("activityId");
        this.id = rs.getInt("id");
        this.name = rs.getString("name");
        this.desc = rs.getString("desc");
        this.concubineComb = rs.getString("concubineComb");
        this.weight = rs.getInt("weight");
        this.reward = rs.getString("reward");
        this.quality = rs.getInt("quality");
        this.firstUnlockReward = rs.getString("firstUnlockReward");

        this.concubineList = StringUtils.stringToIntegerList(this.concubineComb, ";");
        this.rewardList = PropertyHelper.parseNewStringToPropertyList(this.reward);
    }

    public int getActivityId() {
        return activityId;
    }

    public int getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public String getDesc() {
        return desc;
    }

    public String getConcubineComb() {
        return concubineComb;
    }

    public int getWeight() {
        return weight;
    }

    public String getReward() {
        return reward;
    }

    public Set<Integer> getConcubineSet() {
        return new HashSet<>(concubineList);
    }

    public List<List<Property>> getRewardList() {
        return rewardList;
    }

    public int getQuality() {
        return quality;
    }

    public String getFirstUnlockReward() {
        return firstUnlockReward;
    }
}
